package main.Trie;

import java.io.Serializable;

/**
 *
 * @author Jared Hance
 *
 * @param <E> Value type
 */
public class TrieNode<E> extends AbstractTrieNode<TrieNode<E>, E> implements Serializable{

	public TrieNode()
	{
		this(NULL_KEY, null);
	}

	public TrieNode(char key)
	{
		this(key, null);
	}

	public TrieNode(char key, E val)
	{
		super(key, val);
	}

	public TrieNode(E val)
	{
		this(NULL_KEY, val);
	}

	@Override
	public TrieNode<E> createNode() {
		return new TrieNode<E>();
	}

	@Override
	public TrieNode<E> createNode(char key, E value) {
		return new TrieNode<E>(key, value);
	}

    /**
     * Implementation of Comparable interface's compareTo method. A TrieNode
     * is "less than" another TrieNode if its key is lexiographically before
     * the latter TrieNode's key.
     * @param o the TrieNode we are comparing to.
     * @return whether or not this node's key comes before o's key.
     */
	@Override
    public int compareTo(TrieNode<E> o) {
        return getKey() - o.getKey();
    }
}
